import sys
from flask import current_app
from apps import create_app

app= create_app()

@app.route('/')
def hello_world():
    current_app.logger.error('python-logstash: test logstash error message.')
    current_app.logger.info('python-logstash: test logstash info message.')
    current_app.logger.warning('python-logstash: test logstash warning message.')
    # add extra field to logstash message
    extra = {
        'test_string': 'python version: ' + repr(sys.version_info),
        'test_boolean': True,
        'test_dict': {'a': 1, 'b': 'c'},
        'test_float': 1.23,
        'test_integer': 123,
        'test_list': [1, 2, '3'],
    }
    current_app.logger.info('python-logstash: test extra fields', extra=extra)
    return 'Hello World!'

if __name__ == '__main__':
    app.run()
